<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="lib/jquery.js"></script>
  </head>
  <body>
    <script>
      // 1 创建 xhr 对象
      let xhr = new XMLHttpRequest();
      // 2 调用 open函数
      xhr.open("POST", "http://www.liulongbin.top:3006/api/addbook");
      // 3 设置 Content-Type 属性
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      // 4 调用 send
      xhr.send("bookname=水浒传&author=施耐庵&publisher=上海图书出版社");
      // 5 监听事件
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
          console.log(xhr.responseText);
        }
      };
    </script>
  </body>
</html>
